package entity;

import java.util.ArrayList;
import java.util.List;

// 课程类
public class Course {
    private String id;
    private String name;
    private String location;
    private String time;
    private int credit;
    private Teacher teacher; // 授课教师
    private List<Student> students = new ArrayList<>(); // 选课学生

    // 构造方法
    public Course(String id, String name, String location, String time, int credit) {
        this.id = id;
        this.name = name;
        this.location = location;
        this.time = time;
        this.credit = credit;
    }

    // 设置授课教师
    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
        teacher.addTaughtCourse(this);
    }

    // 添加选课学生
    public void addStudent(Student student) {
        students.add(student);
    }

    // 移除选课学生
    public void removeStudent(Student student) {
        students.remove(student);
    }

    // Getter方法
    public String getId() { return id; }
    public String getName() { return name; }
    public String getLocation() { return location; }
    public String getTime() { return time; }
    public int getCredit() { return credit; }
    public Teacher getTeacher() { return teacher; }
    public List<Student> getStudents() { return students; }
}